
// 获取当前fuser和出单日期
var currentUser = V_2.FWatchList.FUser;
var currentDate = V_2.FIssuanceDate;

// 查找分组是否已存在
var groupExists = false;
var targetGroup = null;
for (var i = 0; i < V_GroupedData.size(); i++) {
var group = V_GroupedData.get(i);
if (group.fuser == currentUser) {
groupExists = true;
targetGroup = group;
break;
}
}

// 不存在则创建新分组
if (!groupExists) {
    targetGroup = {
fuser: currentUser,
dates: new ObjectSet() // 存储日期及对应公司
};
V_GroupedData.add(targetGroup);
}

// 按日期分组公司信息
var dateExists = false;
for (var j = 0; j < targetGroup.dates.size(); j++) {
    var dateItem = targetGroup.dates.get(j);
if (dateItem.date == currentDate) {
dateItem.companies.add(V_2); // 假设V_2包含公司信息
dateExists = true;
break;
}
}
if (!dateExists) {
targetGroup.dates.add({
date: currentDate,
companies: new ObjectSet([V_2])
});
}
V_GroupedData; // 返回更新后的分组数据